package org.mcflier.appuntamento.data.model;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;

public class TorrentSource {
	
	private int id;
	private String name, domain, addedBy;
	private Timestamp addedDate;
	private List<String> hdSources;
	private List<String> sdSources;
	private List<String> notClassifSources;
	
	public TorrentSource(int id, String name, String domain){
		if(name == null || domain == null)
			throw new NullPointerException("Name and domain parameters must not be null");
		
		this.id = id;
		this.name = name;
		this.domain = domain;
		
		this.hdSources = new ArrayList<String>();
		this.sdSources = new ArrayList<String>();
		this.notClassifSources = new ArrayList<String>();
	}

	public TorrentSource(int id, String name, String domain, String addedBy, Timestamp addedDate) {
		if(name == null || domain == null)
			throw new NullPointerException("Name and domain parameters must not be null");
		
		this.id = id;
		this.name = name;
		this.domain = domain;
		this.addedBy = addedBy;
		this.addedDate = addedDate;
		
		this.hdSources = new ArrayList<String>();
		this.sdSources = new ArrayList<String>();
		this.notClassifSources = new ArrayList<String>();
	}

	public String getAddedBy() {
		return addedBy;
	}

	public void setAddedBy(String addedBy) {
		this.addedBy = addedBy;
	}

	public Timestamp getAddedDate() {
		return addedDate;
	}

	public void setAddedDate(Timestamp addedDate) {
		this.addedDate = addedDate;
	}

	public int getId() {
		return id;
	}

	public String getName() {
		return name;
	}

	public String getDomain() {
		return domain;
	}
	
	public void addHDSource(String link) {
		if(link==null)
			throw new NullPointerException("Adding resource link must not be null");
		
		if(!this.hdSources.contains(link.trim()))
			this.hdSources.add(link.trim());
	}

	public void addSDSource(String link) {
		if(link==null)
			throw new NullPointerException("Adding resource link must not be null");
		
		if(!this.sdSources.contains(link.trim()))
			this.sdSources.add(link.trim());
	}
	
	public void addNotClassifSource(String link) {
		if(link==null)
			throw new NullPointerException("Adding resource link must not be null");
		
		if(!this.notClassifSources.contains(link.trim()))
			this.notClassifSources.add(link.trim());
	}
	
	public List<String> getHDSources(){
		return this.hdSources;
	}
	
	public List<String> getSDSources(){
		return this.sdSources;
	}
	
	public List<String> getNotClassifSources(){
		return this.notClassifSources;
	}
	
	public String toString(){
		return this.getId()+" "+this.getName()+" "+this.getDomain();
	}
}
